
package metadatabrowser;

import at.fhj.itm.metadata.CheckConstraint;
import at.fhj.itm.metadata.Constraint;
import at.fhj.util.Pair;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jface.viewers.Viewer;

/**
 *
 * @author Seuchter
 */
public class SimpleConstraintContentProvider extends AbstractKeyConstraintContentProvider {

    @Override
    public Object[] getElements(Object o)
    {
      if(!(o instanceof Constraint))
      {
        return null;
      }

      Constraint con = (Constraint) o;

      List<Pair<String,String>> properties = new ArrayList<Pair<String, String>>();
      properties.addAll(createCommonProperties(con));

      if(con instanceof CheckConstraint)
      {
          CheckConstraint chk = (CheckConstraint) con;
          properties.add(new Pair<String, String>("Check Expression", chk.getCheckExpression()));
      }



      return properties.toArray();

    }

    @Override
    public void dispose()
    {

    }

    @Override
    public void inputChanged(Viewer viewer, Object o, Object o1)
    {

    }

}
